function baseCurve(x: number): number {
  if (x < 0) {
    return 0;
  }
  if (x > 1) {
    return 0;
  }
  return Math.sin(x * Math.PI);
}

export const createCurve = (
  totalXDis: number,
  topX: number,
  minY: number,
  maxY: number
) => {
  const beginX = topX - totalXDis / 2;
  const endX = topX + totalXDis / 2;
  const yDis = maxY - minY;

  return (x: number) => {
    if (x < beginX || x > endX) {
      return minY;
    }

    const normalizedX = (x - beginX) / totalXDis;
    return baseCurve(normalizedX) * yDis + minY;
  };
};
